Repository navigation
Partial fix for #15048 Inconsistent error severity for invalidFunctionArg - #8962
Conversation
|
Test results for commit a718c2e (tools/test-my-pr.py, main compared to this PR): Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-8962/ Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong. |
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no new problems. With this change, invalidFunctionArg drops to warning when the value is conditional, the same as zerodiv/zerodivcond, negativeIndex, negativeMemoryAllocationSize and the STL out-of-bounds check. Values that are known and unconditional still give error.
The downgrade also applies when the invalid value reaches the call on every path, and the "condition" is only an early return before it. For example, int n = -1; if (b) return; memset(buf, 0, n); is now a warning. The other checks above already behave this way (int n = 0; if (b) return 0; return 1 / n; gives zerodivcond warning), so this is consistent and not a regression.
Testing
- Built
cppcheckandtestrunnerinpr/, andcppcheckinbase/. ./testrunner TestFunctions: 61 tests, 0 failed, 7 todos.- Compared base and PR on scratch cases with
cppcheck -q --enable=warning --template='{line}:{severity}:{id}:{message}':double d=-1.0; if (b) return d; return std::log(d);(the PR's test case): baseerror, PRwarning.double d=-1.0; return std::log(d);:errorin both, so unconditional known values are unchanged.if (x == -1) {} return std::sqrt(x);:warningin both.int n=-1; if (b) return; memset(buf,0,n);: baseerror, PRwarning.int c=300; if (b) c=1; return isalpha(c);:warningin both.
- For consistency I ran the PR binary on
int n=0; if (b) return 0; return 1/n;, which giveszerodivcondwarning, and onint n=-1; if (b) return; buf[n]=0;, which givesnegativeIndexwarning. The newinvalidFunctionArgseverity matches both. - No crashes or other differences seen.
Automated review of a718c2e by Claude. The pull request was built and tested locally.
No description provided.